Skip to content

fix(compiler): scope per-metric population_filter/guardrails when com… - #240

Merged
mischuh merged 1 commit into
mainfrom
fix/multi-metric-simple-additive-null
Jul 23, 2026
Merged

fix(compiler): scope per-metric population_filter/guardrails when com…#240
mischuh merged 1 commit into
mainfrom
fix/multi-metric-simple-additive-null

Conversation

@mischuh

@mischuh mischuh commented Jul 23, 2026

Copy link
Copy Markdown
Owner

…piling multiple simple metrics together

Compiling several single-kind metrics in one query (e.g. --metrics total_income,total_expenses,net_cashflow) folded every requested metric's population_filter and mandatory_filter guardrails into one shared WHERE clause covering the flat SELECT they all share. When two metrics carried different restrictions, the combined WHERE could never match any row, so every aggregate came back NULL. With more than one metric requested, each metric's own filter/guardrail conditions now scope only its own aggregate via conditional aggregation (SUM(CASE WHEN ... THEN ... END)); single-metric queries are unaffected (still a plain shared WHERE, byte-identical SQL to before).

@mischuh mischuh self-assigned this Jul 23, 2026
…-metric queries

Compiling several single-kind metrics in one query (e.g. --metrics
total_income,total_expenses,net_cashflow) folded every requested metric's
population_filter and mandatory_filter guardrails into one shared WHERE clause
covering the flat SELECT they all share. When two metrics carried different
restrictions, the combined WHERE could never match any row, so every aggregate
came back NULL. With more than one metric requested, each metric's own
filter/guardrail conditions now scope only its own aggregate via conditional
aggregation (CASE WHEN); single-metric queries are unaffected (still a plain
shared WHERE, identical SQL to before).
@mischuh
mischuh force-pushed the fix/multi-metric-simple-additive-null branch from 2b5f56b to d0a86f5 Compare July 23, 2026 06:47
@mischuh
mischuh merged commit 781ae46 into main Jul 23, 2026
5 checks passed
@mischuh
mischuh deleted the fix/multi-metric-simple-additive-null branch July 23, 2026 06:50
@mischuh mischuh mentioned this pull request Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant